package com.ruoyi.user.service.impl;

import com.ruoyi.user.domain.ReviewReply;
import com.ruoyi.user.mapper.ReviewReplyMapper;
import com.ruoyi.user.service.IReviewReplyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class ReviewReplyServiceImpl implements IReviewReplyService {

    @Resource
    private ReviewReplyMapper reviewReplyMapper;

    @Override
    public List<ReviewReply> selectRepliesByReviewId(Long reviewId) {
        return reviewReplyMapper.selectRepliesByReviewId(reviewId);
    }

    @Override
    public int insertReply(ReviewReply reply) {
        if (reply.getReplyTime() == null) {
            reply.setReplyTime(new Date());
        }
        if (reply.getCreateTime() == null) {
            reply.setCreateTime(new Date());
        }
        reply.setUpdateTime(new Date());
        if (reply.getStatus() == null) {
            reply.setStatus(1);
        }
        return reviewReplyMapper.insertReply(reply);
    }
}